#include <stdio.h>
#define MAX 102

int main(){
  char board[MAX][MAX];
  int m,n, count;
  int teste=1;
  char enter;

  for(int i=0;i<MAX;i++){
    for(int j=0;j<MAX;j++){
      board[i][j]='.';
    }
  }
  while(scanf("%d %d\n", &n, &m)!=0 && (n!=0 || m!=0) ){
	  if(teste==1)
		printf("Field #%d:\n", teste++);
	  else
		printf("\nField #%d:\n", teste++);
	
    for(int i=1;i<=n;i++){
      for(int j=1;j<=m;j++){
	scanf("%c", &board[i][j]);
      }
      scanf("%c", &enter);
    }

    for(int i=1;i<=n;i++){
      for(int j=1;j<=m;j++){
	count=0;
	if (board[i][j]=='.'){
	  if(board[i][j-1]=='*')
	    count++;
	  if(board[i][j+1]=='*')
	    count++;
	  if(board[i-1][j-1]=='*')
	    count++;
	  if(board[i-1][j]=='*')
	    count++;
	  if(board[i-1][j+1]=='*')
	    count++;
	  if(board[i+1][j-1]=='*')
	    count++;
	  if(board[i+1][j]=='*')
	    count++;
	  if(board[i+1][j+1]=='*')
	    count++;
	printf("%d", count);
	}else{
	  printf("%c", '*');
	}
      }
      printf("\n");
    }
    for(int i=0;i<MAX;i++){
      for(int j=0;j<MAX;j++){
	board[i][j]='.';
      }
    }

  }
}
